package com.ylx.excel.controller;

import com.ylx.excel.bo.ImportAppBo;
import com.ylx.excel.service.ExcelService;
import com.ylx.excel.service.SyncExcelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@RestController
@Api(tags = "Excel相关")
@RequestMapping("/excel")
public class ExcelController {

    @Autowired
    private ExcelService excelService;
    @Autowired
    private SyncExcelService syncExcelService;

    @ApiOperation(value = "计算成绩")
    @PostMapping("/sumData")
    public void sumData(MultipartFile file, HttpServletResponse response) {
        excelService.sumData(file, response);
    }

    @ApiOperation(value = "导入sim认证Ap和App信息")
    @PostMapping("/importSimAuth")
    public String importSimAuth(@Validated ImportAppBo bo) {
        return excelService.importSimAuth(bo);
    }

    @ApiOperation(value = "导入sim盾的新增数据")
    @PostMapping("/importSim")
    public String importSim(@Validated ImportAppBo bo) {
        return excelService.importSim(bo);
    }

    @ApiOperation(value = "导入sim认证补充的Ap和App信息")
    @PostMapping("/importSimAuthAdd")
    public String importSimAuthAdd(@Validated ImportAppBo bo, HttpServletResponse response) {
        return excelService.importSimAuthAdd(bo,response);
    }

    @ApiOperation(value = "多线程异步导入")
    @PostMapping("/syncImport")
    public String syncImport(MultipartFile file, HttpServletResponse response) {
        return syncExcelService.syncImport(file,response);
    }
}
